const path = require('path');
const fs = require('fs');
const md = require('md');

const README = fs.readFileSync(path.resolve(__dirname, '../README.md'));

console.log('README', README.toString());

const html = md(README.toString());

console.log('html', html);

const wrapperHtml = `
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="icon" href="/favicon.ico" />
    <title>前端图床</title>
</head>
<body>
${html}
</body>
</html>
`

fs.writeFile(path.resolve(__dirname, '../public/index.html'), wrapperHtml, function(err) {
  if(err) {
    console.error(err)
  } else {
    console.log('生成文档html成功')
  }
})

